<template>
  <div class="column">
    <router-view/>
    <div class="panelAll" >
      <div class="boxb"><h2>规模以上工业分行业产值</h2></div>
      <!--
      v-table prop:model => 0:默认 1:头 2:只取有id的
      -->
      <v-table :model="2" :header="this.header1" :body="this.body1"/>
      <v-table :model="2" :header="this.header2" :body="this.body2"/>
      <v-table :model="0" :header="this.header3" :body="this.body3"/>
      <div class="panelSmLonggy-foot"></div>
    </div>
  </div>
</template>

<script>
import axios from 'axios';
import * as echarts from "echarts";
export default {
  name: "gy9",
  mounted() {
    this.$parent.reverseColor9();
  },
  methods: {
    getdata1() {
      this.a = 0;
      this.header1[2].name = this.month+''+'月当月(亿元)'
      this.header1[3].name = this.month+''+'月止累计(亿元)'
      axios.get('http://localhost:9090/industrialIndicators/getKeyEnterprisesProductByGroup', {
        params: {
          year: this.year,
          month:this.month,
        }
      }).then(res => {
        for(var i = 0; i < res.data.length; i++){
          if(res.data[i].number == 0){
            res.data[i].number = null;
          }
          res.data[i].currentMonth = res.data[i].currentMonth.toFixed(0);
        }
        this.a = 1;
        this.body1 = res.data
      })
    },

    getdata2() {
      this.a = 0;
      this.header2[2].name = this.month+''+'月当月(亿元)'
      this.header2[3].name = this.month+''+'月止累计(亿元)'
      axios.get('http://localhost:9090/industrialIndicators/getKeyEnterprisesProductByJudicialPerson', {
        params: {
          year: this.year,
          month:this.month,
        }
      }).then(res => {
        for(var i = 0; i < res.data.length; i++){
          if(res.data[i].number == 0){
            res.data[i].number = null;
          }
          res.data[i].currentMonth = res.data[i].currentMonth.toFixed(0);
        }
        this.a = 1;
        this.body2 = res.data
      })
    },

    getdata3() {
      this.a = 0;
      this.header3[2].name = this.month+''+'月当月(亿元)'
      this.header3[3].name = this.month+''+'月止累计(亿元)'
      axios.get('http://localhost:9090/industrialIndicators/getKeyEnterprisesProductAlone', {
        params: {
          year: this.year,
          month:this.month,
        }
      }).then(res => {
        for(var i = 0; i < res.data.length; i++){
          if(res.data[i].number == 0){
            res.data[i].number = null;
          }
          res.data[i].currentMonth = res.data[i].currentMonth.toFixed(0);
        }
        this.a = 1;
        this.body3 = res.data
      })
    },

    testa(){
      if(this.a == 0){
        this.body1=[]
        this.body2=[]
        this.body3=[]
      }
    },
  },

  watch: {
    '$parent.selectedYear': {
      immediate: true,
      handler(v) {
        this.year = v
      }
    },
    '$parent.selectedMonth': {
      immediate: true,
      handler(v) {
        this.month = v
        this.getdata1();
        this.getdata2();
        this.getdata3();
        this.testa();
        // this.gettop();
        // this.getdata1();
      }
    }
  },
  data() {
    return {
      a:0,
      newDate: new Date(),
      month: null,
      year: null,

      header1: [
        {
          name: "序号",
          value: "number",
        },
        {
          name: "企业名称",
          value: "name",
        },
        {
          name: "八月当月(亿元)",
          value: "currentMonth",
        },
        {
          name: "八月止累计(亿元)",
          value: "currentAccumulate",
        },
        {
          name: "同比±%",
          value: "monthOnMothAccumulate",
        },
      ],


      body1: [],

      header2: [
        {
          name: "序号",
          value: "number",
        },
        {
          name: "企业名称",
          value: "name",
        },
        {
          name: "八月当月(亿元)",
          value: "currentMonth",
        },
        {
          name: "八月止累计(亿元)",
          value: "currentAccumulate",
        },
        {
          name: "同比±%",
          value: "monthOnMothAccumulate",
        },
      ],


      body2: [],

      header3: [
        {
          name: "序号",
          value: "number",
        },
        {
          name: "企业名称",
          value: "name",
        },
        {
          name: "八月当月(亿元)",
          value: "currentMonth",
        },
        {
          name: "八月止累计(亿元)",
          value: "currentAccumulate",
        },
        {
          name: "同比±%",
          value: "monthOnMothAccumulate",
        },
      ],


      body3: [],
    }
  }
}
</script>

<style scoped>

</style>